
package scm.supplyChainManagement.session;

import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import crm.salesOrderProcessing.entity.DeliveryOrderEntity;


@Stateless
@LocalBean
public class DeliveryOrderSessionBean {

    @PersistenceContext
    private EntityManager em;

    public void addDeliveryOrder(DeliveryOrderEntity deliveryOrder) {
        em.persist(deliveryOrder);
    }

    public DeliveryOrderEntity getDeliveryOrderById(Long deliveryOrderId) {
        return em.find(DeliveryOrderEntity.class, deliveryOrderId);
    }

    public List<DeliveryOrderEntity> getAllDeliveryOrders() {
        Query query = em.createQuery("SELECT u FROM DeliveryOrderEntity u");
        return query.getResultList();
    }
   
    public void saveChanges(DeliveryOrderEntity deliveryOrder) {
        em.merge(deliveryOrder);
    }
    
}
